//SamXIAO
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926
#define   SQUARE(x) ((x)*(x))
//double SQUARE(double x) { return x*x;}
#define N_MAX 987654321
#define N_MIN -N_MAX
int f[286][102];

void w1()
{
	int n, m, x, y, ans=0, cnt=0;
	scanf("%d%d", &m, &n);
	//scanf("%d%d", &x, &y);
 	for(int i=1; i<=m; i++){
		for(int j=1; j<=n; j++)
			scanf("%d", &f[i][j]);
  }
	for(int i=1; i<=m; i++){
		for(int j=1; j<=n; j++){
			scanf("%d", &x);
			if(x == f[i][j]) cnt++;
		}
  }
  
  printf("%.2f", cnt*100/float(m*n));

}

int main()
{
	w1();
  return 0;
}
